# 定义一个方法 无参数 做一件事情 就是打印一下
def print_hello():
    print("hello")


print_hello()  # 调用方法


# 定义一个有参数的方法
def print_hello1(username):
    print(username)


print_hello1("name")


# 定义一个有参数默认值的方法
def print_hello2(username='tom'):
    print(username)


print_hello2()


# 定义一个有返回值的方法
def print_hello3(username='tom'):
    return username


obj = print_hello3("你猜猜我猜不猜")
print(obj)


# 定义一个接受List的方法 并传入副本进行操作
def listValues(List):
    if isinstance(List, list):
        for v in List:
            print(v)


listsdemo = [0, 1, 2, 3, 4, 5, 6]

listValues(listsdemo[:])
print(listsdemo)


#  传递任意参数的实参
def print_more(*names):
    for name in names:
        print(name)


print_more("hello ", "world", 1, 2, 3, 4)


#  传递任意参数的实参和固定参数
def print_more2(age, *names):
    print(age)
    for name in names:
        print(name)


print_more2(19999, "hello ", "world", 1, 2, 3, 4)
